package com.cutie.entry.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.cutie.core.dao.DBManager;
import com.cutie.core.dao.IBuilder;
import com.cutie.entry.model.VideoDictionary;

public class VideoDictionaryDao {

	private static final String find_property_sql = "select video_dictionary_id,entry_id,entry_name,video_source from video_dictionary where entry_id=?";
	@SuppressWarnings("unchecked")
	public List<VideoDictionary> getVideos(Integer entryId) throws SQLException{
		try{
			Object[] data = new Object[]{ entryId };
			List<VideoDictionary> videoList = (List<VideoDictionary>)DBManager.executeQuery(find_property_sql, data, new IBuilder(){

				@Override
				public Object build(ResultSet rs) throws SQLException {
					List<VideoDictionary> list = new ArrayList<VideoDictionary>();
					while(rs.next()){
						VideoDictionary video = new VideoDictionary();
						video.setVideoDictionaryId(rs.getInt("video_dictionary_id"));
						video.setEntryId(rs.getInt("entry_id"));
						video.setEntryName(rs.getString("entry_name"));
						video.setVideoSource(rs.getString("video_source"));
						
						list.add(video);
					}
					return list;
				}
				
			});
			return videoList;
		}catch(SQLException e){
			e.printStackTrace();
			throw e;
		}
	}
}
